import requests

if __name__ == '__main__':
    headers = {
        'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36 Edg/89.0.774.68'
    }
    # url = 'https://www.sogou.com/web?query=' + keyworld
    # page = requests.get(url)
    url = 'https://www.sogou.com/web'
    keyworld = input('请输入你要搜索的关键词：')
    param = {
        'query':keyworld
    }
    page = requests.get(url=url, params=param, headers=headers)
    text = page.text
    # print(text)
    with open('{}.html'.format(keyworld), 'w', encoding='utf-8') as fp:
        fp.write(text)
    print('网页采集完毕！！！')